# Qdrant Self Query Retriever

This example shows how to use a self query retriever with a Qdrant vector store.

## Usage

import IntegrationInstallTooltip from "@mdx_components/integration_install_tooltip.mdx";

<IntegrationInstallTooltip></IntegrationInstallTooltip>

```bash npm2yarn
npm install @langchain/openai @langchain/community @langchain/qdrant @qdrant/js-client-rest
```

import CodeBlock from "@theme/CodeBlock";
import Example from "@examples/retrievers/qdrant_self_query.ts";

<CodeBlock language="typescript">{Example}</CodeBlock>

You can also initialize the retriever with default search parameters that apply in
addition to the generated query:

```typescript
const selfQueryRetriever = SelfQueryRetriever.fromLLM({
  llm,
  vectorStore,
  documentContents,
  attributeInfo,
  /**
   * We need to create a basic translator that translates the queries into a
   * filter format that the vector store can understand. We provide a basic translator here.
   * You can create your own translator by extending BaseTranslator
   * abstract class. Note that the vector store needs to support filtering on the metadata
   * attributes you want to query on.
   */
  structuredQueryTranslator: new QdrantTranslator(),
  searchParams: {
    filter: {
      must: [
        {
          key: "metadata.rating",
          range: {
            gt: 8.5,
          },
        },
      ],
    },
    mergeFiltersOperator: "and",
  },
});
```

See the [official docs](https://qdrant.tech/documentation/concepts/filtering/) for more on how to construct metadata filters.
